package com.xzzz.irda.guardcat.core.constants;

import cn.hutool.core.lang.UUID;
import com.xzzz.irda.guardcat.core.metric.GuardcatMachineController;
import com.xzzz.irda.guardcat.core.metric.GuardcatJvmController;

/**
 * @author xzzz
 */
public interface GuardcatConstant {
    /**
     * 判断机器下线的阈值:30 秒
     */
    long MACHINE_OFFLINE_THRESHOLD = 1000 * 30;
    /**
     * 判断应用进入死亡的阈值: 1分钟
     */
    long MACHINE_DEAD_THRESHOLD = 1000 * 60;
    /**
     * 机器ID, 每次启动是不同的机器ID
     */
    String MACHINE_ID = UUID.fastUUID().toString(true).toUpperCase();
    /**
     * 服务端的包路径
     */
    String SERVER_PACKAGE = "com.xzzz.irda.guardcat.server";
    /**
     * 服务端警告监听的包路径
     */
    String SERVER_LISTENER_PACKAGE = "com.xzzz.irda.guardcat.server.alert.listener";
    /**
     * 客户端的包路径
     */
    String CLIENT_PACKAGE = "com.xzzz.irda.guardcat.client";

    /**
     * 生产环境标识
     */
    String ENV_PROD  = "PROD";
    String ENV_DEV   = "DEV";
    String ENV_LOCAL = "LOCAL";

    interface API {
        /**
         * 服务端心跳地址
         */
        String HEARTBEAT = "/guardcat/heartbeat";
        /**
         * 服务端警告地址
         */
        String ALERT_ADD = "/guardcat/server/alert/add";
        /**
         * {@link GuardcatMachineController#getMachineMetric()}
         */
        String METRIC_MACHINE      = "/guardcat/core/machine/cpuAndMem";
        String METRIC_MACHINE_HOST = "/guardcat/core/machine/hostName";
        /**
         * GC: {@link GuardcatJvmController#getGarbageCollectorInfos()}
         * JMM: {@link GuardcatJvmController#getMemoryInfo()}
         * 线程列表: {@link GuardcatJvmController#getAllThreadMsgSet()}
         * 线程快照: {@link GuardcatJvmController#getFullThreadDumpMsg()}
         * 线程信息: {@link GuardcatJvmController#getSimpleJvmThreadInfo()}
         * 内存统计: {@link GuardcatJvmController#getHeapMemoryObjectStatistics()}
         * 死锁信息: {@link GuardcatJvmController#getDeadlockedThreadMsgSet()}
         * 操作系统: {@link GuardcatJvmController#getOperatingSystemInfo()}
         * JVM基本信息: {@link GuardcatJvmController#getJvmInfo()}
         */
        String METRIC_JVM_GC             = "/guardcat/core/jvm/getGarbageCollectorInfos";
        String METRIC_JVM_JMM            = "/guardcat/core/jvm/getMemoryInfo";
        String METRIC_THREAD_LIST        = "/guardcat/core/jvm/getAllThreadMsgSet";
        String METRIC_THREAD_DUMP        = "/guardcat/core/jvm/getFullThreadDumpMsg";
        String METRIC_SIMPLE_THREAD_INFO = "/guardcat/core/jvm/getSimpleJvmThreadInfo";
        String METRIC_OBJECT_STAT        = "/guardcat/core/jvm/getHeapMemoryObjectStatistics";
        String METRIC_DEAD_LOCK          = "/guardcat/core/jvm/getDeadlockedThreadMsgSet";
        // 操作系统
        String METRIC_SYSTEM_INFO        = "/guardcat/core/jvm/getOperatingSystemInfo";
        String METRIC_JVM_INFO           = "/guardcat/core/jvm/getJvmInfo";

        // 应用关系
        String METRIC_APP_RELATION     = "/guardcat/core/app/relation";
        // Rocker 使用的 TOPIC
        String METRIC_ROCKMET_TOPICS   = "/guardcat/core/rocketmq/topics";

    }
}
